<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		姓名：<input type="text" id="username" onpaste="fun2()" />
		<hr>
		<div id="">
			
		</div>
		<script type="text/javascript">
			var username = document.getElementById("username")
			username.onchange=function(){
				var div = document.querySelector("div")
				div.innerHTML=`值被修改为:${username.value}`
			}
			var div = document.querySelector("div")
			div.addEventListener("copy",fun1)
			function fun1(){
				alert("不允许复制")
				event.preventDefault()
			}
			function fun2(){
				alert("不允许粘贴")
				event.preventDefault()
			}
		</script>
	</body>
</html>
